package itdfq.dfq.Creational_Pattern.jiandangongchang;

/**
 * @Author GocChin
 * @Date 2021/3/13 16:31
 * @Blog: itdfq.com
 * @QQ: 909256107
 */
public class PhoneFactory {
    public static  Phone producePhone(String name) throws Exception{
        if (name.equals("vivo")){
            System.out.println("手机厂生产vivo手机");
            return new VivoPhone();
        }else if(name.equals("小米")){
            System.out.println("手机厂生产小米手机");
            return new MiPhone();
        }else {

            throw new Exception("Sorry，暂时不能成产这种手机");
        }
    }
}
